﻿@using LanDBom.Models
@using LanDBom.Resources
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Genertals.cshtml";
}

<div class="row col-12">
    <div class="col-2 nav-item" id="divjibeng">@Resource.String48</div>
    <div class="col-2 nav-item" id="divbeizhu">@Resource.String49</div>
    <div class="col-2 nav-item" id="divtuzhi">@Resource.String50</div>
    <div class="col-2 nav-item" id="divweituo" style="display:none">@Resource.String51</div>
</div>
<div>
    <div id="divsw1">
        <fieldset class="boun">
            <legend class="len">申请单信息</legend>
            <table id="BiaoTo" class="table-app">
                @foreach (var item in ViewBag.APPSH as List<Applications>)
                {
                    <tr>
                        <td>
                            @Html.Label(Resource.String429): @item.App_Kehu
                        </td>
                        <td>
                            @Html.Label(Resource.String430):
                            <input type="text" id="txtdan" name="dan" readonly="readonly" value="@item.AP_bian">
                        </td>
                    </tr>

                    <tr>
                        <td>
                            @Html.Label("发起人:")
                            <input type="datetime" id="txtqishi" name="qishi" readonly="readonly" value="@Session["jisn"]">
                        </td>

                    </tr>
                    <tr>
                        <td>
                            @Html.Label(Resource.String433):
                            <label id="hsijddd"> @item.APP_name</label>
                        </td>
                        <td>@Html.Label(Resource.String435): @item.APP_Zhong</td>
                    </tr>
                    <tr>
                        <td>@Html.Label(Resource.String431): @item.App_qishi</td>
                        <td>@Html.Label(Resource.String432):@item.App_JTime</td>
                    </tr>
                    <tr>
                        <td>@Html.Label(Resource.String437): @item.App_dizhi</td>
                        <td>@Html.Label(Resource.String434): @item.App_lei</td>
                    </tr>
                    <tr>
                        <td>@Html.Label(Resource.String438): @item.App_sho</td>
                        <td>
                            @Html.Label(@Resource.String77):
                            <lable id="Shenji">@item.APP_she</lable>
                        </td>
                    </tr>
                }
            </table>
        </fieldset>
    </div>
    <div id="divsw2" style="display:none">
        <div class="">
            <fieldset class="boun">
                <legend class="len">@Resource.String83</legend>
                <div id="div2_div">

                </div>
                <textarea rows="4" class="col-11" id="RZ_xznr"></textarea><br />
                <input type="button" name="name" value="@Resource.tj" id="RZ_tjrz" />
            </fieldset>
        </div>
    </div>
    @*图纸备注*@
    <div id="divsw3" style="display:none">
        <div class="">
            <fieldset class="boun">
                <legend class="len">@Resource.String84</legend>
                <table class="table tab">
                    <thead style="text-align:center;">
                        <tr style="background-color: #6e95bc">
                            <td>@Resource.String85</td>
                            <td>@Resource.String86</td>
                            <td>@Resource.String87</td>
                            <td>@Resource.String88</td>
                            <td>@Resource.String89</td>
                        </tr>
                    </thead>
                    <tbody id="div3__tb">
                    </tbody>
                </table>
            </fieldset>
        </div>
    </div>
</div>

<div>
    <table class="table table-sm gun">
        <thead class="thead-light">
            <tr>
                <th>@Resource.String1226</th>
                <th>@Resource.String1227</th>
            </tr>
        </thead>
        <tbody id="td_wlxx">
            @foreach (var item in ViewBag.AASHEN as List<Informa>)
            {
                <tr>
                    <td>@item.Inf_wu</td>
                    <td>@item.Inf_gong</td>
                </tr>
            }
        </tbody>
    </table>
</div>
<div id="WT_dh_mb" style="display:none;position:fixed;background-color:white;top:200px;width:660px;left:300px;z-index:1000;border:1px black solid;">
    <div id="WJ_ID" style="display:none"></div>
    <table>
        <tr>
            <td>@Resource.String1228：</td>
            <td id="WT_dhr"></td>
        </tr>
        <tr>
            <td>@Resource.String1229</td>
            <td><textarea id="WT_dhly"></textarea></td>
        </tr>
        <tr>
            <td id="WT_qdbh">@Resource.String1230</td>
            <td id="WT_qxbh">@Resource.String1231</td>
        </tr>
    </table>
</div>
<input type="button" name="name" value="@Resource.String1232" id="dabiO1" />
<input type="button" name="name" value="@Resource.String1233" id="dabiOLP" />
<input type="button" name="name" value="@Resource.String1234" id="dabokjj" />
<input type="button" name="name" value="@Resource.String1231" id="fanhui" />
@section scripts{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        $(function () {
            //通过
            $(document).on("click", "#dabiO1", function () {
                var Binas = $("#txtdan").val()
                var Name = $("#Login_N").text()
                $.ajax({
                    url: '/ShenPI/Index',
                    type: 'POST',
                    data: { "stetede": 1, "bians": Binas, "Namesed": Name },
                    success: function (data) {
                        //返回是否是他审批
                        alert(data)
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            })
            $("#fanhui").click(function () {
                window.location.href = "/Home/Zuye";
            })
            $(document).on("click", "#dabiOLP", function () {
                var Name = $("#Login_N").text()
                $("#WT_dhr").text(Name)
                $("#WT_dh_mb").show();
            })
            $(document).on("click", "#WT_qxbh", function () {
                $("#WT_dh_mb").hide();
                $("#WT_dhly").text("");
            })

            $(document).on("click", "#dabokjj", function () {
                var Binas = $("#txtdan").val()
                $.ajax({
                    url: '/ShenPI/Index',
                    type: 'POST',
                    data: { "stetede": 3, "bians": Binas },
                    success: function (data) {
                        //返回是否是他审批
                        alert(data)
                        window.location.href = "/Procure/Overview";
                    },
                    error: function () {
                        alert("系统错误!");
                    }
                })
            })
            $(document).on("click", "#WT_qdbh", function () {
                var Binas = $("#txtdan").val()
                var Name = $("#Login_N").text()
                var MMK = $("#WT_dhly").val()
                if (MMK != "") {
                    $.ajax({
                        url: '/ShenPI/Index',
                        type: 'POST',
                        data: { "stetede": 2, "bians": Binas, "Namesed": Name, "liyou": MMK },
                        success: function (data) {
                            //返回是否是他审批
                            alert(data)
                        },
                        error: function () {
                            alert("系统错误!");
                        }
                    })
                } else {
                    alert("请输入理由！")
                }
            })
        })

        $(function () {
            gettuz()//搜索图纸信息
            gettbz()//搜索备注信息
            //点击切换基础信息，备注信息，图纸沟通
            $(function () {
                $("#divjibeng").click(function (e) {
                    $("#divsw1").css({ "display": "block" });
                    $("#divsw2").css({ "display": "none" });
                    $("#divsw3").css({ "display": "none" });
                })
                $("#divbeizhu").click(function (e) {
                    $("#divsw2").css({ "display": "block" });
                    $("#divsw1").css({ "display": "none" });
                    $("#divsw3").css({ "display": "none" });
                })
                $("#divtuzhi").click(function (e) {
                    $("#divsw3").css({ "display": "block" });
                    $("#divsw1").css({ "display": "none" });
                    $("#divsw2").css({ "display": "none" });
                })
            })
            //写入日志
            $(document).on("click", "#RZ_tjrz", function () {
                var now = new Date($.now());
                var year = (now.getFullYear()).toString();
                var month = (now.getMonth() + 1).toString();
                var date = (now.getDate()).toString();
                var hours = (now.getHours()).toString()
                var minutes = (now.getMinutes()).toString()

                //组合当前日期
                var sqrq = year + "/" + month + "/" + date + " " + hours + ":" + minutes
                var rzxx = {
                    B_Bian: $("#shenDan").val(),
                    B_BR: $('#Login_N').val(),
                    B_Date: sqrq,
                    B_bei: $('#RZ_xznr').val(),

                };
                console.log(rzxx)
                $.ajax({
                    url: "/Contracts/AddLogs",
                    type: "POST",
                    data: rzxx,
                    success: function (data) {
                        alert(data)
                        gettbz()
                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })
            })
            //获取图纸信息
            function gettuz() {
                var kan = $("#txtdan").val();
                $.ajax({
                    url: "/Application/Application",
                    type: "POST",
                    data: { "App_ban": kan, "state": 3 },
                    success: function (sjik) {

                        $("#div3__tb tr").remove();
                        $.each(sjik, function (i, item) {
                            var x = item.De_dizhi
                            var $tr = $(`
                                                                <tr class="log_tr">
                                                                    <td style="display:none">${item.DE_id}</td>
                                                                    <td>${i + 1}</td>
                                                                    <td>${item.De_dizhi}</td>
                                                                    <td>${item.De_shijian}</td>
                                                                    <td>${item.De_ren}</td>
                                                                    <td><a href="#" id="log_SC">删除</a>/<a href="/Contracts/Download_file?path=${x}" id="log_SZ">下载</a></td>
                                                                </tr>
                                                                `);
                            $("#div3__tb").append($tr);
                        })
                    },
                    error: function () {
                        alert("erroer");
                    },
                })
            }
            //获取备注信息
            function gettbz() {
                var kan = $("#shenDan").val();
                $.ajax({
                    url: "/Application/Application",
                    type: "POST",
                    data: { "App_ban": kan, "state": 4 },
                    success: function (sjik) {
                        $("#div2_div div").remove();
                        $.each(sjik, function (i, item) {
                            var $tr = $(`
                                                                <div>
                                                                    <div>
                                                                        <span>${item.B_BR}</span><span>${item.B_Date}</span>
                                                                    </div>
                                                                    <div>
                                                                        ${item.B_bei}
                                                                    </div>
                                                                </div>`);
                            $("#div2_div").append($tr);
                        })
                    },
                    error: function () {
                        alert("erroer");
                    },
                })
            }
        })
    </script>

}